package com.ley.dish.web.shop.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.ley.dish.base.entity.Result;
import com.ley.dish.web.shop.entity.Shop;
import com.ley.dish.web.shop.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

    /**
     * 查询全部
     * @return
     */
    @RequestMapping("/list")
    public List<Shop> list(){
        List<Shop> list = shopService.findAllShop();
        return list;
    }

    /**
     * 分页
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @RequestMapping("pageList")
    public Result pageList(@RequestParam Integer pageNumber, @RequestParam Integer pageSize){
        Result result = new Result();
        Page page = new Page<>(pageNumber,pageSize);
        Page<Shop> pageStu = shopService.findAllShopPage(page);
        result.setData(pageStu.getRecords());
        return result;

    }

}
